﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ReTS.UI.Native
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            //TODO: Transfer to Registration Screen
            Registration regScreen = new Registration();
            regScreen.Previous = this;
            regScreen.SetUsername(txtUsername.Text);
            regScreen.Show();
            this.Hide();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (Validate_Login(txtUsername.Text, txtPassword.Text))
            {
                Dashboard dash = new Dashboard();
                // TODO: Any data that needs to be passed along here (such as user credentials)
                dash.rootForm = this;
                dash.Show();
                this.Hide();
            }
        }

        private bool Validate_Login(string username, string password)
        {
            //TODO: Validate Login and transfer to Dashboard. For now always returns true.
            return true;
        }

        private void txtPassword_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btnLogin_Click(sender, e);
        }

        private void txtUsername_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btnLogin_Click(sender, e);
        }

        public void SetUsername(string user)
        {
            txtUsername.Text = user;
        }
    }
}
